﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="buyerRangeEdit1.aspx.cs" Inherits="PeisongWeb.admin.buyerRange" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ Register TagName="top" Src="controls/top.ascx" TagPrefix="uc1" %>
<%@ Register TagName="menu" Src="controls/menu.ascx" TagPrefix="uc2" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>企业日常采购初始化</title>
    <style type="text/css">
    .header-row{}
    </style>
    <!--#include file="style.inc"-->
    <script src="/app_common/scripts/jquery-1.3.2.min.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(function() {
            $('#chkSelectedAll').click(function() {
                if ($(this).attr('checked')) {
                    $(':checkbox', $('#admin_list_content')).attr('checked', true);
                } else {
                    $(':checkbox', $('#admin_list_content')).attr('checked', null);
                }
            });
        });

        function checktxtlength(obj) {
            if (obj.value.length > 50) {
                obj.select();
                alert("输入长度请不要超过50个字符（一个汉字占两个字符）！");
            }
        }

        function checktxttype(obj) {
            var test = /^\d+(\.\d{1,2})?$/;
            if (test.test(obj.value)) {
                if (obj.value == "0") {
                    obj.value = "1"
                    return true;
                }
                else
                    return true;
            }
            else {
                obj.value = "1"
                return true;
            }
        }

        function delSelectedConfirm(obj) {
            var k = [];
            $('#tablerange').find("tr").siblings().css('color', 'black').each(function() {
                if ($(this).find('td').eq(0).find('input').attr('checked')) {
                    //alert($(this).find('td').eq(6).find('input').eq(0).val());
                    var productid = $(this).find('td').eq(0).find('input').parent().attr('productId');
                    var businessnature = $(this).find('td').eq(6).find('input').eq(0).val();
                    var amount = $(this).find('td').eq(7).find('input').eq(0).val();
                    var remark = $(this).find('td').eq(8).find('input').eq(0).val();
                    k.push(productid + '|' + businessnature + '!' + amount+'*'+remark);
                }
            });

           
            if (k != 0) {
                $('#hdSelectedProductIds').val(k.join(','));
                return confirm('你确定要添加这' + k.length  + '项吗?');
            } else {
                alert('无任何可以添加的项.');
                return false;
            }
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="sm1" runat="server">
    </asp:ScriptManager>
    <ext:ScriptManager ID="ScriptManager1" runat="server" />
    <uc1:top ID="Top1" runat="server" />
    <uc2:menu ID="Menu1" runat="server" />
    <div id="admin-body">
        <h2 class="section-cms">企业日常采购初始化</h2>
        <span>
            <ext:Button runat="server" ID="btnReturn" Text="返回" AutoPostBack="true" 
            Icon="ArrowSwitch" onclick="btnReturn_Click"></ext:Button>
        </span>
        <p>
            &nbsp;</p>
        <ext:Panel ID="Panel1" runat="server" Title="企业日常采购初始化" BodyStyle="padding:5px 5px 0"
            Width="960" Frame="true" ButtonAlign="Center">
            <Body>
                <div id="admin_edit_content_search">
                    <asp:UpdatePanel runat="server" ID="UP1">
                        <Triggers>
                            <asp:PostBackTrigger ControlID="lbn_search" />
                        </Triggers>
                        <ContentTemplate>
                            <ul>
                                <li style="width: 175px;">
                                    <label>
                                        大 类：</label>
                                    <asp:DropDownList runat="server" ID="ddl_CategoryRoot" DataTextField="parentname" DataValueField="parentId"
                                        AutoPostBack="True" OnSelectedIndexChanged="ddl_CategoryRoot_SelectedIndexChanged">
                                    </asp:DropDownList>
                                </li>
                                <li style="width: 175px;">
                                    <label>
                                        小 类：</label>
                                    <asp:DropDownList runat="server" ID="ddl_CategorySub" DataTextField="childname" DataValueField="categoryId">
                                    </asp:DropDownList>
                                </li>
                                <li style="width: 220px;">
                                    <label style="width: 75px;">
                                        商品编号:</label>
                                    <asp:TextBox ID="txt_ProductNo" runat="server" Width="120px"></asp:TextBox>
                                </li>
                                <li style="width: 220px;">
                                    <label style="width: 75px;">
                                        商品名称:</label>
                                    <asp:TextBox ID="txt_ProductName" runat="server" Width="120px"></asp:TextBox>
                                </li>
                                <li style="width: auto;">
                                    <asp:LinkButton ID="lbn_search" runat="server" Text="［搜索］" CausesValidation="false"
                                        OnClick="lbn_search_Click"></asp:LinkButton>
                                    <asp:LinkButton ID="lbn_reset" runat="server" Text="[重置]" CausesValidation="false"
                                        OnClick="lbn_reset_Click"></asp:LinkButton>
                                </li>
                            </ul>
                        </ContentTemplate>
                    </asp:UpdatePanel>
                </div>
            </Body>
        </ext:Panel>
        <p>
            &nbsp;</p>
        <div id="admin_list_content" style="width: 960px;">
            <table id="tablerange" cellpadding="0" cellspacing="0">
                <tr class="header-row">
                    <th>
                        <input type="checkbox" id="chkSelectedAll" />
                    </th>
                    <th>
                        序号
                    </th>
                    <th>
                        大类
                    </th>
                    <th>
                        小类
                    </th>
                    <th>
                        商品编号
                    </th>
                    <th>
                        商品名称
                    </th>
                    <th>
                        商品级别
                    </th>
                    <th>
                        预订数量
                    </th>
                    <th>
                        备注
                    </th>
                    <th>
                        操作
                    </th>
                </tr>
                <asp:Repeater ID="rpt_list" runat="server" OnItemCommand="rpt_list_ItemCommand">
                    <ItemTemplate>
                        <tr class='<%# Container.ItemIndex%2==0? "row-alt":"alt"  %>' style="color:Black">
                            <td>
                                <asp:CheckBox runat="server" ID="chkSelected" productId='<%# DataBinder.Eval(Container.DataItem,"productId") %>' />
                            </td>
                            <td>
                                <%# Container.ItemIndex+1 %>
                            </td>
                            <td>
                                <%# DataBinder.Eval(Container.DataItem,"parentName") %>
                            </td>
                            <td>
                                <%# DataBinder.Eval(Container.DataItem, "childname")%>
                            </td>
                            <td>
                                <%# DataBinder.Eval(Container.DataItem,"productNo") %>
                            </td>
                            <td>
                                <%# DataBinder.Eval(Container.DataItem,"name") %>
                            </td>
                            <td>
                               <asp:Label ID="lblBN" runat="server" Text=' <%# Convert.ToString(DataBinder.Eval(Container.DataItem, "businessnaturename"))%>' />
                                <input id="Hidden1" type="hidden"  value='<%# DataBinder.Eval(Container.DataItem, "businessNature")%>'/>
                            </td>
                            <td>
                            <asp:TextBox ID="txt_amount" runat="server" Width="20px" Text="1" onblur="return checktxttype(this)"></asp:TextBox>
                            <%# DataBinder.Eval(Container.DataItem, "unit")%>
                            </td>
                            <td >
                                <asp:TextBox ID="txt_Remarks" runat="server" Width="120px" onblur="return checktxtlength(this)"></asp:TextBox>
                                
                            </td>
                            <td style="width:12%">
                                <asp:LinkButton CommandName="AddTo" CommandArgument='<%# DataBinder.Eval(Container.DataItem,"productId")+","+DataBinder.Eval(Container.DataItem,"businessNature") %>'
                                    runat="server" ID="lblDel">选用</asp:LinkButton>
                            </td>
                        </tr>
                    </ItemTemplate>
                </asp:Repeater>
                <tr>
                    <td colspan="7">
                        <asp:Button runat="server" ID="btnDelSelected" Text="添加选择项" OnClientClick="return delSelectedConfirm(this);"
                            OnClick="btnDelSelected_Click" />
                        <asp:Button runat="server" ID="btnRootCategoryDel" Text="按大类选用" OnClientClick='return confirm("你确定要添加该大类下所有商品吗?");'
                            OnClick="btnRootCategoryDel_Click" />
                        <asp:Button runat="server" ID="btnSubCategoryDel" Text="按小类选用" OnClientClick='return confirm("你确定要添加该小类下所有商品吗?");'
                            OnClick="btnSubCategoryDel_Click" />
                        <%--<asp:Button ID="btnSecondLevel" runat="server" Text="按大类二级选用" 
                            OnClientClick='return confirm("你确定要添加该大类下所有二级商品吗?");' CommandName="0"
                            OnCommand="btnSecondLevel_Command" />
                        <asp:Button ID="btnSecondLevel0" runat="server" Text="按小类二级选用" 
                            OnClientClick='return confirm("你确定要添加该小类下所有二级商品吗?");' CommandName="1" 
                            OnCommand="btnSecondLevel_Command" />--%>
                    </td>
                </tr>
            </table>
            <div id="page">
                <webdiyer:AspNetPager ID="AspNetPager1" NumericButtonType="Text" MoreButtonType="Text"
                    OnPageChanged="AspNetPager1_PageChanged" runat="server" AlwaysShow="True" PageSize="20"
                    InvalidPageIndexErrorMessage="无效页码" PageIndexOutOfRangeErrorMessage="页码超出范围"
                    ShowCustomInfoSection="Left" CustomInfoHTML=" 每页%PageSize%条记录 | 总共%RecordCount%条记录 "
                    CustomInfoTextAlign="Left" HorizontalAlign="Right" NextPageText="下一页" FirstPageText="首页"
                    LastPageText="末页" PrevPageText="上一页">
                </webdiyer:AspNetPager>
            </div>
        </div>
    </div>
    <asp:HiddenField runat="server" ID="hdSelectedProductIds" />
    </form>
</body>
</html>
